package org.log4jeditor.xml.editor;

import java.lang.annotation.Annotation;

import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;

/**
 * FIXME : when using this class, the model and document do not seem to be updated. 
 * If a test that modifies the document content, the following test does not read a clean new document, 
 * yet it uses the instance that was modified in the previous test -> assertions fail :-/
 */
@Deprecated
public class CustomBlockJUnit4ClassRunner extends BlockJUnit4ClassRunner {

	/**
	 * Creates a BlockJUnit4ClassRunner to run {@code klass}
	 * 
	 * @throws InitializationError
	 *             if the test class is malformed.
	 */
	public CustomBlockJUnit4ClassRunner(Class<?> clazz) throws InitializationError {
		super(clazz);
	}

	@Override
	/**
	 * Returns a {@link Statement}: run all non-overridden {@code @After}
	 * methods on this class and superclasses before running {@code next}; all
	 * After methods are always executed: exceptions thrown by previous steps
	 * are combined, if necessary, with exceptions from After methods into a
	 * {@link MultipleFailureException}.
	 */
	protected Statement withAfters(FrameworkMethod method, Object target,
			Statement statement) {
		Statement stmt = super.withAfterClasses(statement);
		for(Annotation annotation : method.getAnnotations()) {
			if(annotation instanceof DirtiesProjectFiles) {
				//((AbstractUITestCase)target).setRequiresProjectCleanup(true);
			}
		}
		return stmt;
	}

	
}
